﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class DefineShapeTag : Tag, IHasCharacterId
    {
        public ushort ShapeId
        {
            get;
            protected set;
        }

        public RectangleRecord ShapeBounds
        {
            get;
            protected set;
        }

        public ShapeWithStyle Shapes
        {
            get;
            protected set;
        }

        public virtual ShapeType TagType
        {
            get
            {
                return ShapeType.Shape1;
            }
        }

        protected DefineShapeTag(TagCodes code, int len, int offset)
            : base(code,len,offset)
        {

        }

        public DefineShapeTag(int len, int offset)
            : this(TagCodes.DefineShape, len, offset)
        {

        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            long StartIndex = reader.Position;

            ShapeId = reader.ReadUInt16();

            ShapeBounds = new RectangleRecord();
            ShapeBounds.SwfDeserialize(reader);

            Shapes = new ShapeWithStyle(TagType);
            Shapes.SwfDeserialize(reader);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #region IHasCharacterID Members

        public ushort Id
        {
            get { return ShapeId; }
        }

        #endregion
    }
}
